A actions tree is an object constituted of nodes, representing all the actions exchanged (performed) beetween server and clients.
Now we know all the actions that will be exchanged, we can represent the actions tree as below :
Tree
client
message
public
private
server
message
Let’s take back the tree example above, and see what role the different nodes have :
The two important roles are the root as it has access to all its children, and the action as it is to it we associate encoders and handlers
Let’s stay in our example, and assume the tree is already built and assigned to the name ‘tree’ :
>>> #to access to the action private
>>> tree.client.message.private
< Node object at 0x0000000002C2EE80>
Each Node is an attribute of its parent. This mechanism is keystrokes economic, clear and readable despite being also a bit unconventional.
The “magic” is awfully simple : each Node (except the root) holds an automatically assigned bytecode. When passing an Node instance to the built-in str(), you obtain a string of bytecodes. The last one, is the one attributed to the Node instance, the one before it comes from its parent, etc...
within our example :
>>> str(tree.client.message.private)
'\x00\x00\x01'
>>> str(tree.server.message)
'\x01\x00'